#include <QCoreApplication>
#include<QSettings>
#include<QDebug>

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    QSettings settings("settring.ini",QSettings::IniFormat);
    //读取Ini文件中的值
    QString username=settings.value("General/username").toString();
    QString language=settings.value("General/language").toString();
    int port=settings.value("Network/port").toInt();

    qDebug()<<"username: "<<username;
    qDebug()<<"language: "<<language;
    qDebug()<<"port:"<<port;

    settings.beginGroup("General");
    settings.setValue("username","Alice");
    settings.setValue("language","zh_CN");
    settings.endGroup();

    settings.beginGroup("Network");
    settings.setValue("port", 80);
    settings.endGroup();

    username = settings.value("General/username").toString();
    language = settings.value("General/language").toString();
    port = settings.value("Network/port").toInt();

    qDebug() << "modified username:" << username;
    qDebug() << "modified language:" << language;
    qDebug() << "modified port:" << port;


    //  打印读取到的值
    return a.exec();
}
